/**
 * 
 */
package org.cuatrovientos.erp.business;

import java.util.List;

import org.apache.log4j.Logger;
import org.cuatrovientos.erp.dao.DepartmentDAOInterface;
import org.cuatrovientos.erp.model.Department;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author natalia
 * This class implements DepartmenBOInterface
 *
 */
public class DepartmentBO implements DepartmentBOInterface{

	// Get log4j logger
		private static final Logger logger = Logger.getLogger(DepartmentBO.class);
		
		@Autowired
	    private DepartmentDAOInterface departmentDAO;
		
	/**
	 * @param int id
	 * @return Department department
	 * This method returns a department selected by it's id
	 */
	@Override
	public Department selectById(int id) {
		logger.info("selectById: " + id);
		return departmentDAO.selectById(id);
	}
	
	/**
	 * @return All the departments we have in the database
	 */
	@Override
	public List<Department> selectAll() {
		logger.info("selectAll: ");
		return departmentDAO.selectAll();
	}
	
	/**
	 * @return The number of departments we have in the database
	 */
	@Override
	public List<Department> search(String name) {
		logger.info("search : " + name);
		return departmentDAO.search(name);
	}
	
	/**
	 * @param int id
	 * This method deletes the department selected by id
	 */
	@Override
	public void deleteById(int id) {
		logger.info("delete by: " + id + " id");
		departmentDAO.deleteById(id);
	}
	
	/**
	 * @param Department department
	 * This method insert a department in the database passed by parameter
	 */
	@Override
	public void insert(Department department) {
		logger.info("insert: " + department);
		departmentDAO.insert(department);
	}
	
	/**
	 * @param Department department
	 * This method updates a department passed by parameter
	 */
	@Override
	public void update(Department department) {
		logger.info("update: " + department);
		departmentDAO.update(department);
	}
	
	/**
	 * @param Department department
	 * This method deletes a department passed by parameter
	 */
	@Override
	public void delete(Department department) {
		logger.info("delete: " + department);
		departmentDAO.delete(department);
	}

}
